<!DOCTYPE html>
<html>
<head>
    <title>Call Graph</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" integrity="sha256-iq5ygGJ7021Pi7H5S+QAUXCPUfaBzfqeplbg/KlEssg=" crossorigin="anonymous" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js" integrity="sha256-JuQeAGbk9rG/EoRMixuy5X8syzICcvB0dj3KindZkY0=" crossorigin="anonymous"></script>

    {% if not phrackify %}
    <style type="text/css">
        #mynetwork {
          height: 100%;
            background-color: #232625;
        }
        body {
            background-color: #232625;
            color: #ffffff;
            font-size: 10px;
        }
        html, body {
          height: 95%;
        }
    </style>
    {% else %}
    <style type="text/css">
        #mynetwork {
            height: 100%;
            background-color: #ffffff;
        }
        body {
            background-color: #ffffff;
            color: #000000;
            font-size: 10px;
            font-family: "courier new";
        }
        html, body {
          height: 95%;
        }
    </style>
    {% endif %}

    <script>
        var options = {{opts | tojson}};
        var nodes = {{nodes | tojson}};
        var edges = {{edges | tojson}};
    </script>
</head>
<body>
<p>{{ title }}</p>
<div id="mynetwork"></div>
<script type="text/javascript">
    var container = document.getElementById('mynetwork');

    var nodesSet = new vis.DataSet(nodes);
    var edgesSet = new vis.DataSet(edges);
    var data = {'nodes': nodesSet, 'edges': edgesSet}

    var gph = new vis.Network(container, data, options);
    gph.on("click", function (params) {
        // parse node id
        var nodeID = params['nodes']['0'];
        if (nodeID) {
            var clickedNode = nodesSet.get(nodeID);

            if(clickedNode.isExpanded) {
                clickedNode.label = clickedNode.truncLabel;
            }
            else {
                clickedNode.label = clickedNode.fullLabel;
            }

            clickedNode.isExpanded = !clickedNode.isExpanded;

            nodesSet.update(clickedNode);
        }
    });
</script>
</body>
</html>
